package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author zhushuainan
 * @title: ContractCompareMenuEnum
 * @projectName xbb-pro
 * @description: 合同比对菜单
 * @date 2022/11/18 10:15
 */
@Getter
public enum ContractCompareMenuEnum {

    /**
     * 合同比对
     */
    CONTRACT_COMPARE_RESULT(XbbRefTypeEnum.CONTRACT_COMPARE_RESULT.getName(), XbbRefTypeEnum.CONTRACT_COMPARE_RESULT.getAlias(), XbbRefTypeEnum.CONTRACT_COMPARE_RESULT.getCode(),
            AccessLinkEnum.CONTRACT_COMPARE_RESULT, "","home", MenuTypeEnum.MENU.getType());


    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;

    /**
     * 所属于哪个页面，home：首页；controlCenter：管理中心
     */
    private String belong;
    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;

    ContractCompareMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, String belong, Integer type) {
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.belong = belong;
        this.type = type;
    }

    public static ContractCompareMenuEnum getByAlias(String alias) {
        for ( ContractCompareMenuEnum contractCompareMenuEnum: values()) {
            if(contractCompareMenuEnum.getAlias().equals(alias)) {
                return contractCompareMenuEnum;
            }
        }
        return null;
    }

    public static ContractCompareMenuEnum getByCode(Integer code) {
        for( ContractCompareMenuEnum contractCompareMenuEnum: values()) {
            if(contractCompareMenuEnum.getCode().equals(code)){
                return contractCompareMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}

